package com.ficus.road.maintain.core.model.zh.bridgehotel;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * @author xiawen yang
 * @date 2022/3/22 下午2:09
 */
@Data
public class BridgeHotelZH {
    private String monitortype;

    private String wgs84;

    private String bridgename;

    private String address;

    private String latitude;

    private String longitude;

    private String createdate;

    private String roadid;

    private String deviceid;

    private String roadname;

    public BridgeHotel convert2BridgeHotel(BridgeHotelZH zh, Date modificationTime, Date creationTime) {
        BridgeHotel bridgeHotel = new BridgeHotel();
        bridgeHotel.setBridgeName(zh.getBridgename());
        bridgeHotel.setMonitorType(zh.getMonitortype());
        bridgeHotel.setRoadId(zh.getRoadid());
        bridgeHotel.setRoadName(zh.getRoadname());
        bridgeHotel.setCreateDate(creationTime);
        bridgeHotel.setDeviceId(zh.getDeviceid());
        bridgeHotel.setModificationTime(modificationTime);
        String wgs84 = zh.getWgs84();
        if (StringUtils.isNotEmpty(wgs84)) {
            String[] strings = wgs84.split(",");
            bridgeHotel.setLongitude(strings[0]);
            bridgeHotel.setLatitude(strings[1]);
        }
        return bridgeHotel;
    }
}
